from functools import reduce

def f(x):
    return x*x
res1 = map(f,[1,2,3,4,5])
print(list(res1))

temp = map(str,[1,2,3,4,5])
print(list(temp))

def add(x, y):
    return x + y
temp1 = reduce(add,[1,2,3,4,5])
print(temp1)


def count1():
    fs = []
    for i in range(1, 4):
        def f():
             return i*i
        fs.append(f)
    return fs

def count():
    def f(j):
        def g():
            return j*j
        return g
    fs = []
    for i in range(1, 4):
        fs.append(f(i)) # f(i)立刻被执行，因此i的当前值被传入f()
    return fs

f1, f2, f3 = count()

print(f1())
print(f2())
print(f3())




